//
//  HNSH_BusinessCircleDetailFooterView.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/3/6.
//

#import "HNSH_BusinessCircleDetailFooterView.h"

@interface HNSH_BusinessCircleDetailFooterView ()

/* addressBgView */
@property (nonatomic, strong) UIView *addressBgView;
/* addressImgV */
@property (nonatomic, strong) UIImageView *addressImgV;
/* 导航 */
@property (nonatomic, strong) UIButton *dhButton;
/* addressLabel */
@property (nonatomic, strong) UILabel *addressLabel;

/* jyfwTitleLabel */
@property (nonatomic, strong) UILabel *jyfwTitleLabel;
/* jyfwLabel */
@property (nonatomic, strong) UILabel *jyfwLabel;

/* zstzTitleLabel */
@property (nonatomic, strong) UILabel *zstzTitleLabel;
/* zstzLabel */
@property (nonatomic, strong) UILabel *zstzLabel;

/* lxdhTitleLabel */
@property (nonatomic, strong) UILabel *lxdhTitleLabel;
/* lxdhLabel */
@property (nonatomic, strong) UILabel *lxdhLabel;

/* yysjTitleLabel */
@property (nonatomic, strong) UILabel *yysjTitleLabel;
/* yysjLabel */
@property (nonatomic, strong) UILabel *yysjLabel;

@end

@implementation HNSH_BusinessCircleDetailFooterView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self configUI];
    }
    return self;
}

- (void)setModel:(HNSH_BusinessCircleListModel *)model {
    _model = model;
    self.jyfwLabel.text = model.category_name;
    self.yysjLabel.text = model.business_time;
    self.lxdhLabel.text = model.phone;
    self.addressLabel.text = [NSString stringWithFormat:@"%@%@",model.region_name,model.address];
    self.zstzLabel.text = [model.reward_text isNotBlank] ? model.reward_text : @"   ";
    
}

- (void)configUI {
    [self addSubview:self.jyfwTitleLabel];
    [self addSubview:self.jyfwLabel];

    [self addSubview:self.zstzTitleLabel];
    [self addSubview:self.zstzLabel];
    
    [self addSubview:self.lxdhTitleLabel];
    [self addSubview:self.lxdhLabel];
    
    [self addSubview:self.yysjTitleLabel];
    [self addSubview:self.yysjLabel];
    
    [self addSubview:self.addressBgView];
    [self.addressBgView addSubview:self.addressImgV];
    [self.addressBgView addSubview:self.addressLabel];
    [self.addressBgView addSubview:self.dhButton];
    
    [self.jyfwTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(12);
        make.height.mas_equalTo(17);
    }];
    [self.jyfwLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.jyfwTitleLabel.mas_right);
        make.top.equalTo(self.jyfwTitleLabel.mas_top);
        make.height.mas_equalTo(17);
    }];
    
    [self.zstzTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.equalTo(self.jyfwLabel.mas_bottom).offset(8);
        make.height.mas_equalTo(17);
    }];
    [self.zstzLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
    [self.zstzLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.zstzTitleLabel.mas_right);
        make.top.equalTo(self.zstzTitleLabel.mas_top);
        make.width.mas_equalTo(kScreenWidth-100);
    }];
    
    [self.lxdhTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.equalTo(self.zstzLabel.mas_bottom).offset(8);
        make.height.mas_equalTo(17);
    }];
    [self.lxdhLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.lxdhTitleLabel.mas_right);
        make.top.equalTo(self.lxdhTitleLabel.mas_top);
        make.height.mas_equalTo(17);
    }];
    
    [self.yysjTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.equalTo(self.lxdhLabel.mas_bottom).offset(8);
        make.height.mas_equalTo(17);
    }];
    [self.yysjLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.yysjTitleLabel.mas_right);
        make.top.equalTo(self.yysjTitleLabel.mas_top);
        make.height.mas_equalTo(17);
    }];
    
    
    [self.addressBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.right.mas_equalTo(-16);
        make.top.equalTo(self.yysjLabel.mas_bottom).offset(12);
        make.height.mas_equalTo(56);
    }];
    
    [self.addressLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
    [self.addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(32);
        make.top.mas_equalTo(8);
        make.width.mas_equalTo(kScreenWidth-116);
    }];
    
    [self.dhButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.bottom.mas_equalTo(0);
        make.width.mas_equalTo(48);
    }];
}

#pragma mark lazy
- (UILabel *)jyfwTitleLabel {
    if (!_jyfwTitleLabel) {
        _jyfwTitleLabel = [[UILabel alloc]init];
        _jyfwTitleLabel.text = @"经营范围：";
        _jyfwTitleLabel.textColor = [UIColor appGrayLabelColor];
        _jyfwTitleLabel.font = [UIFont systemFontOfSize:12];
    }
    return _jyfwTitleLabel;
}

- (UILabel *)jyfwLabel {
    if (!_jyfwLabel) {
        _jyfwLabel = [[UILabel alloc]init];
        _jyfwLabel.text = @"";
        _jyfwLabel.textColor = [UIColor appBlackLabelColor];
        _jyfwLabel.font = [UIFont systemFontOfSize:12];
    }
    return _jyfwLabel;
}

- (UILabel *)zstzTitleLabel {
    if (!_zstzTitleLabel) {
        _zstzTitleLabel = [[UILabel alloc]init];
        _zstzTitleLabel.text = @"赠送通证：";
        _zstzTitleLabel.textColor = [UIColor appGrayLabelColor];
        _zstzTitleLabel.font = [UIFont systemFontOfSize:12];
    }
    return _zstzTitleLabel;
}

- (UILabel *)zstzLabel {
    if (!_zstzLabel) {
        _zstzLabel = [[UILabel alloc]init];
        _zstzLabel.text = @"";
        _zstzLabel.textColor = [UIColor appBlackLabelColor];
        _zstzLabel.font = [UIFont systemFontOfSize:12];
        _zstzLabel.numberOfLines = 0;
    }
    return _zstzLabel;
}

- (UILabel *)lxdhTitleLabel {
    if (!_lxdhTitleLabel) {
        _lxdhTitleLabel = [[UILabel alloc]init];
        _lxdhTitleLabel.text = @"联系电话：";
        _lxdhTitleLabel.textColor = [UIColor appGrayLabelColor];
        _lxdhTitleLabel.font = [UIFont systemFontOfSize:12];
    }
    return _lxdhTitleLabel;
}

- (UILabel *)lxdhLabel {
    if (!_lxdhLabel) {
        _lxdhLabel = [[UILabel alloc]init];
        _lxdhLabel.text = @"";
        _lxdhLabel.textColor = [UIColor appBlackLabelColor];
        _lxdhLabel.font = [UIFont systemFontOfSize:12];
    }
    return _lxdhLabel;
}

- (UILabel *)yysjTitleLabel {
    if (!_yysjTitleLabel) {
        _yysjTitleLabel = [[UILabel alloc]init];
        _yysjTitleLabel.text = @"营业时间：";
        _yysjTitleLabel.textColor = [UIColor appGrayLabelColor];
        _yysjTitleLabel.font = [UIFont systemFontOfSize:12];
    }
    return _yysjTitleLabel;
}

- (UILabel *)yysjLabel {
    if (!_yysjLabel) {
        _yysjLabel = [[UILabel alloc]init];
        _yysjLabel.text = @"";
        _yysjLabel.textColor = [UIColor appBlackLabelColor];
        _yysjLabel.font = [UIFont systemFontOfSize:12];
    }
    return _yysjLabel;
}

- (UIView *)addressBgView {
    if (!_addressBgView) {
        _addressBgView = [[UIView alloc]init];
        _addressBgView.backgroundColor = [UIColor appBGColor];
        _addressBgView.layer.cornerRadius = 8.0f;
        _addressBgView.layer.masksToBounds = YES;
    }
    return _addressBgView;
}

- (UILabel *)addressLabel {
    if (!_addressLabel) {
        _addressLabel = [[UILabel alloc]init];
        _addressLabel.text = @"浙江省杭州市西湖区中大银泰..";
        _addressLabel.textColor = [UIColor appBlackLabelColor];
        _addressLabel.font = [UIFont systemFontOfSize:14];
        _addressLabel.numberOfLines = 2;
    }
    return _addressLabel;
}

- (UIImageView *)addressImgV {
    if (!_addressImgV) {
        _addressImgV = [[UIImageView alloc]initWithFrame:CGRectMake(12, 10, 16, 16)];
        _addressImgV.image = [UIImage imageNamed:@"b_circle_detail_address_icon"];
    }
    return _addressImgV;
}

- (UIButton *)dhButton {
    if (!_dhButton) {
        _dhButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _dhButton.frame = CGRectMake(kScreenWidth-32, 0, 48, 56);
        [_dhButton setTitle:@"" forState:UIControlStateNormal];
        [_dhButton setTitleColor:[UIColor appBlueLabelColor] forState:UIControlStateNormal];
        _dhButton.titleLabel.font = [UIFont systemFontOfSize:12];
        [_dhButton setImage:[UIImage imageNamed:@"b_circle_detail_daohang_icon"] forState:UIControlStateNormal];
        [_dhButton HNSH_layoutButtonWithEdgeInsetsStyle:HHZXButtonStyleTextBottom imageTitleSpace:0];
        WeakSelf(weakSelf);
        [[_dhButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
            if (weakSelf.dhBlock) {
                weakSelf.dhBlock();
            }
        }];
    }
    return _dhButton;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
